/*
 * ServerCommunicator.h
 *
 *  Created on: 24/05/2014
 *      Author: javier
 */

#ifndef SERVERCOMMUNICATOR_H_
#define SERVERCOMMUNICATOR_H_

#include <string>
#include "ClientSocket.h"
#include "Properties.h"
#include "ComunicacionException.h"
#include "Positionable.h"
#include "Mutex.h"
#include "Thread.h"
#include <list>
#include <vector>
#include "BLQueue.h"
#include "Message.h"

class BZPController;

class ServerMessageSender: public Thread {
public:
	ServerMessageSender(BZPController* controller, ClientSocket& socket);
	void sendMovementUp();
	void sendMovementDown();
	void sendMovementRight();
	void sendMovementLeft();
	void sendNewGameMessage();
	void sendSelectCampaign(std::string & idCampania,
			std::string & nombrePartida);
	void sendSelectedMatch(std::string & idPartida);
	void sendStartMatch(bool comenzar, string & idPartida);
	void sendJoinGameMessage();
	void sendDropBomb();

	void sendResetGameMessage();

	void sendLoadNextScenario();
	void run();
	void init();
	bool isConnected();
	virtual ~ServerMessageSender();
	void setIdJugador(int idJugador);

private:
	BZPController* controller;
	Properties properties;
	ClientSocket socket;
	bool conected;
	Mutex mutex;
	BLQueue<Message> messagesQueue;
	int idJugador;
	int idPartida;
	std::string nombrePartida;
};

#endif /* SERVERCOMMUNICATOR_H_ */
